import 'package:flutter/material.dart';
import 'package:flutter_demo/anim/anim_1_test.dart';
import 'package:flutter_demo/anim/share_anim_test.dart';
import 'package:flutter_demo/img/transform_img_test.dart';
import 'package:flutter_demo/listgrid/pull_refresh_test.dart';
import 'package:flutter_demo/listgrid/scroll_listener_test.dart';
import 'package:flutter_demo/position/abs_position_test.dart';
import 'package:flutter_demo/richtxt/rich_txt_test.dart';
import 'package:flutter_demo/shape/round_box_test.dart';
import 'package:flutter_demo/shape/tag_test.dart';
import 'package:flutter_demo/view_pager_test.dart';

import 'input/text_input_controller_test.dart';

//void main() => runApp(new CustomThemeApp());
//void main() => runApp(new ImgApp());
//void main() => runApp(new HApp());
//void main() => runApp(new MultiList());
//void main() => runApp(new GridTxt());
//void main() => runApp(new TapButton());
//void main() => runApp(new SwipeList());
//void main() => runApp(new RoutePage());
//void main() => runApp(new TodoListPage());
//void main() => runApp(new OnResultPage());
//void main() => runApp(new JsonReq());
//void main() => runApp(new ToggleBox());
//void main() => runApp(new EditApp());
//void main() => runApp(new Grid9());

void main() => runApp(new MaterialApp(
      title: 'FlutterDemo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: HomePage(title: 'FlutterDemo'),
      routes: pages,
    ));

class HomePage extends StatefulWidget {
  final String title;

  HomePage({Key key, this.title}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    var routeLists = pages.keys.toList();

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Container(
        child: ListView.builder(
            itemCount: pages.length,
            itemBuilder: (context, index) {
              return InkWell(
                onTap: () {
                  Navigator.of(context).pushNamed(routeLists[index]);
                },
                child: Card(
                  child: Container(
                    alignment: Alignment.centerLeft,
                    margin: EdgeInsets.symmetric(horizontal: 10),
                    height: 50,
                    child: Text(pageNames[index]),
                  ),
                ),
              );
            }),
      ),
    );
  }
}

const pageNames = [
  "控制器",
  "圆角box",
  "滑动监听",
  "Transform",
  "下拉刷新",
  "绝对定位",
  "标签",
  "共享元素",
  "动画",
  "富文本",
  "ViewPapger",
  "悬停"
];

var pages = <String, WidgetBuilder>{
  "widget/controller": (context) {
    return new TextInputControllerTest();
  },
  "widget/round": (context) {
    return new RoundBoxTest();
  },
  "widget/scroll": (context) {
    return new ScrollListenerTest();
  },
  "widget/transform": (context) {
    return new TransformImageTest();
  },
  "widget/refresh": (context) {
    return new PullRefreshTest();
  },
  "widget/positioned": (context) {
    return new AbsPositionTest();
  },
  "widget/tag": (context) {
    return new TagTest();
  },
  "widget/shareAnim": (context) {
    return new ShareAnimTest();
  },
  "widget/anim1": (context) {
    return new Anim1Test();
  },
  "widget/rich": (context) {
    return new RichTextTest();
  },
  "widget/viewpager": (context) {
    return new ViewPagerTest();
  },
  "widget/floating": (context) {
    return new ViewPagerTest();
  },
};
